﻿@model Property4U.Models.Feedback

@{
    ViewBag.Title = "Create";
}

<div class="row">
    <!-- Page Header -->
    <div class="col-lg-12">
        <h1 class="page-header">@ViewBag.Title</h1>
    </div>
    <!--End Page Header -->
</div>

@{
    var param = (Request.Params["reportAbuse"] != null) ? Request.Params["reportAbuse"].Equals("True") : false;
}

@* Post parameters with form submit for reportAbuse (Flags) *@
@using (Html.BeginForm(null, null, new { reportAbuse = param }, FormMethod.Post, new { id = "CreateFeedback" }))
{
    @Html.AntiForgeryToken()
    
    <div class="form-horizontal">
        <h4>
        @{if (param){ @("Flags");}else{ @("Feedback");}}
        </h4>
        <hr />
        @Html.ValidationSummary(true, "", new { @class = "text-danger" })
        <div class="alert alert-warning" role="alert"><strong>Feedback/Flag</strong> is only allowed for <strong>Requested Properties</strong></div>
        <div class="form-group">
            @Html.LabelFor(model => model.PropertyID, "PropertyID", htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.DropDownList("PropertyID", (SelectList)ViewBag.PropertyIDList, String.Empty, htmlAttributes: new { @class = "form-control" })
                @Html.ValidationMessageFor(model => model.PropertyID, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.MemberID, "MemberID", htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.DropDownList("MemberID", (SelectList)ViewBag.MemberIDList, String.Empty, htmlAttributes: new { @class = "form-control" })
                @Html.ValidationMessageFor(model => model.MemberID, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.For, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EnumDropDownListFor(model => model.For, htmlAttributes: new { @class = "form-control" })
                @Html.ValidationMessageFor(model => model.For, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.Title, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.Title, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.Title, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.Description, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.Description, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.Description, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group process-feedback">
            @Html.LabelFor(model => model.AgentRating, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EnumDropDownListFor(model => model.AgentRating, htmlAttributes: new { @class = "form-control" })
                @Html.ValidationMessageFor(model => model.AgentRating, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group process-feedback">
            @Html.LabelFor(model => model.AgentReview, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.AgentReview, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.AgentReview, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group process-feedback">
            @Html.LabelFor(model => model.OverallExperience, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EnumDropDownListFor(model => model.OverallExperience, htmlAttributes: new { @class = "form-control" })
                @Html.ValidationMessageFor(model => model.OverallExperience, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.FeedbackOn, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.FeedbackOn, new { htmlAttributes = new { @class = "form-control", @Value = ViewBag.FeedbackOn, @readonly = "readonly" } })
                @Html.ValidationMessageFor(model => model.FeedbackOn, "", new { @class = "text-danger" })
            </div>
        </div>

        @Html.HiddenFor(model => model.LastEdit)

        <div class="form-group">
            <div class="col-md-offset-2 col-md-10">
                <input type="submit" value="Create" class="btn btn-default" />
            </div>
        </div>
    </div>
}

<div>
    @Html.ActionLink("Back to List", "Index")
</div>

@section scripts {
    <script type="text/javascript" src="~/Scripts/FeedbackFor.js"></script>

    @* Check url parameter reportAbuse isNumeric and set defualts EnumDropDownListFor  *@
    <script type="text/javascript">
        $(function () {
            if ($.isNumeric("@Request.Params["PID"]")) {
                $("#PropertyID").val('@Request.Params["PID"]');
            }

            if ("@param" != "False")
                $("#For").val('1');
            else
                $("#For").val('2');
        });
    </script>
}